<template>
    <div class="top">
        <div class="left">
            <span class="lbtn" @click="goHome">首页</span>
        </div>
        <div class="center">
            <div class="title">智慧旅游可视化大数据平台</div>
        </div>
        <div class="right">
            <span class="rbtn">统计报告</span>
            <span class="time">当前时间: {{ time }}</span>
        </div>
    </div>
</template>

<script setup lang="ts">
import router from '@/router';
import { ref, onMounted, onBeforeUnmount } from 'vue';
// 引入时间插件
import moment from 'moment';
// 存储当前事件
const time = ref<any>(moment().format('YYYY年MM月DD日 hh时mm分ss秒'))
const timer = ref(0)


const goHome = () => {
    router.push('/home')
}
//组件挂载完毕要实时的更新当前的时间
onMounted(() => {
    timer.value =  setInterval(() => {
         time.value = (moment().format('YYYY年MM月DD日 hh时mm分ss秒'))
    }, 1);
})
onBeforeUnmount(() => {
    clearInterval(timer.value)
})
</script>

<style scoped lang="scss">
.top {
    width: 100%;
    height: 30px;
    display: flex;

    .left {
        flex: 1.5;
        background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
        background-size: cover;
        color: #29FCFF;


        .lbtn {
            width: 136px;
            height: 40px;
            float: right;
            text-align: center;
            line-height: 40px;
            color: #29FCFF;
            font-weight: 600;
            font-size: 16px;
            font-style: italic;
            background: url(../../images/dataScreen-header-btn-bg-l.png) no-repeat;
            background-size: 100% 100%;
            cursor: pointer;

        }
    }

    .center {
        flex: 2;

        .title {
            width: 100%;
            height: 80px;
            line-height: 80px;
            text-align: center;
            color: #29FCFF;
            font-weight: 600;
            font-size: 24px;
            font-style: italic;

            background: url(../../images/dataScreen-header-center-bg.png) no-repeat;
            background-size: 100% 100%;
        }
    }

    .right {
        flex: 1.5;
        background: url(../../images/dataScreen-header-right-bg.png) no-repeat;

        background-size: cover;

        .rbtn {
            width: 136px;
            height: 40px;
            float: left;
            text-align: center;
            line-height: 40px;
            color: #29FCFF;
            font-weight: 600;
            font-size: 16px;
            font-style: italic;
            background: url(../../images/dataScreen-header-btn-bg-r.png) no-repeat;
            background-size: 100% 100%;
            cursor: pointer;

        }

        .time {
            margin-left: 10%;
            color: #29FCFF;
            font-size: 14px;
            line-height: 40px;
            font-weight: 500;
            font-style: italic;
        }
    }
}
</style>